@extends('home.public.base')

@section('title', '订单确认')

@section('content')
    <style>
        .rel.focus {
            color: #999988;
        }

        .rel .addr_delete:hover {
            color: red;
        }

    </style>
    <div class="bg-f5f5f5 p-b-10">
        <div class="currentloc bg-f5f5f5 clear">
            <div class="center f12">
                <div class="fl">
                    <a href="/">首页</a>
                    <span>/</span>填写订单
                </div>
                <a href="http://crm2.qq.com/page/portalpage/wpa.php?uin=7796335593&amp;cref=/&amp;ref=&amp;f=1&amp;ty=1&amp;ap=&amp;as="
                   class="fr qqbtn tc f-666" target="_blank">QQ在线交谈</a>
                <span class="fr f-666">服务热线：0755-86380505、0755-86380506 (8:00－24:00)</span>
            </div>
        </div>
        <form action="" method="post" id="orderform">
            <input type="hidden" name="step" value="done"/>
            <input type="hidden" name="chk_code" value="ed93df2fc0701ec41069f777e0c9cc6f"/>
            <div class="md-order center bg-fff">
                <div class="address clear b-b-3">
                    <span class="title fl f16">收货地址</span>
                    <div class="cont fl" id="address_list">
                        @foreach($adress as $adres)
                            <a href="javascript:void(0)" class="fl rel" data-addrid="{{$adres['id']}}">
                                <p class="clear">
                                    <span class="fl">{{$adres['name']}}</span><span
                                            class="fr f12">{{$adres['tel']}}</span></p>
                                <p class="m-t-10 f12">
                                    {{$adres['sheng']}}{{$adres['shi']}}{{$adres['qu']}}
                                    <br/>
                                    {{$adres['address']}}
                                </p>
                                <p>
                                    <em onclick="location.href='/adressdel/{{$adres['id']}}';"
                                        class="addr_delete">删除</em>
                                </p>
                            </a>
                        @endforeach
                        <a href="javascript:void(0)" class="fl addnew">
                            <i class="icon-bgr icon-add1 m-r-8"></i>
                            新增收货地址
                        </a>
                    </div>
                </div>

                <div class="pay-way clear m-x-65 rel">
                    <div class="mask dn"></div>
                    <span class="title fl lh50 f16">支付方式</span>
                    <div class="cont fl checkbox tc">
                        <a href="javascript:void(0)" data-js-bind="select_payment" data-pay_id="1"
                           class="fl focus">在线支付</a>


                    </div>
                </div>

                <div class="goods-list clear m-x-65 rel">
                    <div class="mask dn"></div>
                    <p class="clear p-b-10"><span class="title f16">商品清单</span>
                        <a href="/cart" class="fr"><i class="icon-bgr icon-arrowL m-r-10"></i>返回购物车修改</a></p>
                    <div class="cont tc">
                        <table>
                            <tbody>
                            @foreach($goods['goods'] as $key => $good)
                                <tr data-rec-id="{{$key}}">
                                    <td width="45%" class="tl"><a href="javascript:void(0)"><img
                                                    src="/{{$good['options']['imgs']}}"
                                                    class="m-r-10 dib"/><span
                                                    class="dib overtxt">{{$good['name']}}</span></a></td>
                                    <td width="25%"></td>
                                    <td>{{$good['price']}} x {{$good['num']}}</td>
                                    <td>{{$good['total']}}</td>
                                </tr>
                            @endforeach
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="pay-detail clear m-x-65 rel">

                    <div class="fr">
                        <table>
                            <tbody>
                            <tr>
                                <td>商品件数：</td>
                                <td class="tr" id="total_real_goods_count">{{$goods['total_rows']}}</td>
                            </tr>
                            <tr>
                                <td>金额合计：</td>
                                <td class="tr" id="total_goods_price">￥{{$goods['total']}}</td>
                            </tr>

                            <tr>
                                <td class="total">应付总额：</td>
                                <td class="total tr" id="total_amount">￥{{$goods['total']}}</td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
                @csrf
                <input type="hidden" id="addrid" name="addrid" value="">
                <input type="hidden" name="paytype" value="1">
                <div class="order-btn tr rel">
                    <div class="mask dn"></div>
                    <button type="button" id="submit_order" class="btn-red-single submit_order">提交订单</button>
                </div>
            </div>
        </form>
    </div>

    <script>
        $(function () {
            $('#submit_order').click(function () {
                if ($('#addrid').val() == '') {
                    alert('收货地址为空');
                    return false;
                }
                $('#orderform').submit();
            })
        })

    </script>


    <style>
        #addadress {
            display: none
        }
    </style>
    <div id="addadress" class="aui_state_focus"
         style="position: absolute; left: 30%; top: 10%; width: auto; z-index: 2008;">
        <div class="aui_outer">
            <table class="aui_border">
                <tbody>
                <tr>
                    <td class="aui_nw"></td>
                    <td class="aui_n"></td>
                    <td class="aui_ne"></td>
                </tr>
                <tr>
                    <td class="aui_w"></td>
                    <td class="aui_center">
                        <table class="aui_inner">
                            <tbody>
                            <tr>
                                <td class="aui_header">
                                    <div class="aui_titleWrap">
                                        <div class="aui_title" style="cursor: move;"></div>
                                        <a class="aui_close" href="javascript:/*artDialog*/;">×</a></div>
                                </td>
                            </tr>
                            <tr>
                                <td class="aui_main" style="width: auto; height: auto;">
                                    <div class="aui_content" style="padding:20px 25px">
                                        <div class="md-form md-edit-addr" data-address_id="0">
                                            <form action="/adress" method="post">
                                                @csrf
                                                <p class="f18 fb">新增收货地址</p>
                                                <div class="line m-t-40 clear"><span class="title fl">收货人</span>
                                                    <div class="addrcont fl"><input type="text" name="name"
                                                                                    placeholder="请输入姓名" value=""
                                                                                    class="inp">
                                                        <p class="error-tips f12 f-d93732">&nbsp;</p></div>
                                                </div>
                                                <div class="line clear"><span class="title fl">手机号码</span>
                                                    <div class="addrcont fl"><input type="tel" name="tel"
                                                                                    placeholder="请输入手机号" value=""
                                                                                    class="inp">
                                                        <p class="error-tips f12 f-d93732">&nbsp;</p></div>
                                                </div>
                                                <div class="line clear"><span class="addresstitle fl">收货地区</span>
                                                    <div class="addrcont fl">
                                                        <div id="distpicker1">
                                                            <select name="sheng"></select>
                                                            <select name="shi"></select>
                                                            <select name="qu"></select>
                                                        </div>
                                                        <script src="https://cdn.bootcss.com/distpicker/2.0.5/distpicker.min.js"></script>
                                                        <script>
                                                            $("#distpicker1").distpicker();
                                                        </script>
                                                        <p class="error-tips f12 f-d93732">&nbsp;</p></div>
                                                </div>
                                                <div class="line clear"><span class="title fl">详细地址</span>
                                                    <div class="addrcont fl"><textarea name="address" placeholder="详细地址"
                                                                                       class="address-area"></textarea>
                                                        <p class="error-tips f12 f-d93732">&nbsp;</p></div>
                                                </div>
                                                <div class="line clear">
                                                    <button type="submit" href="javascript:void(0)"
                                                            class="btn-red-sml ani-bg fr"
                                                            id="save_info">新增
                                                    </button>
                                                </div>
                                            </form>
                                        </div>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td class="aui_footer">
                                    <div class="aui_buttons" style="display:none"></div>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </td>
                    <td class="aui_e"></td>
                </tr>
                <tr>
                    <td class="aui_sw"></td>
                    <td class="aui_s"></td>
                    <td class="aui_se" style="cursor: se-resize;"></td>
                </tr>
                </tbody>
            </table>
        </div>
    </div>

    <script>
        $('.addnew').click(function () {
            $('#addadress').show();

        })
        $('.aui_close').click(function () {
            $('#addadress').hide();
        })
        $('.rel').click(function () {
            $(this).addClass('focus').siblings().removeClass('focus');
            $('#addrid').val($(this).attr('data-addrid'));
        })


    </script>
@endsection